package com.joe.httpclient;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;

public class HttpClientTest {
	
	public static final String baseURL = "http://localhost:8080/nirvana/json";
	
	/**
	 * @param args
	 * @throws IOException 
	 * @throws HttpException 
	 */
	public static void main(String[] args) throws HttpException, IOException {
		// TODO Auto-generated method stub
		String requestStr = baseURL+"?func=addUser&data=xmldatastr";
		HttpClient httpClient = new HttpClient();
		PostMethod postMethod = new PostMethod(requestStr);
		int responseCode = httpClient.executeMethod(postMethod);
		if(responseCode == 200){
			String responseStr = postMethod.getResponseBodyAsString();
			System.out.println(responseStr);
		}
		System.err.println(responseCode);
	}

}
